#pragma once

template<class Iterator, class Pef, class Ptr>
struct Reverse_iterator
{
	typedef Reverse_iterator<Iterator, Pef, Ptr> self;

	Iterator cur;

	Reverse_iterator(Iterator it)
		:cur(it)
	{}

	Ptr operator->()
	{
		return &(operator*());
	}

	self& operator++()
	{
		--cur;
		return *this;
	}

	self operator++(int)
	{
		Iterator tmp = cur;
		--cur;
		return tmp;
	}

	self& operator--()
	{
		++cur;
		return *this;
	}

	self operator--(int)
	{
		Iterator tmp = cur;
		++cur;
		return tmp;
	}

	Pef operator*()
	{
		Iterator tmp = cur;
		--tmp;
		return *tmp;
	}

	bool operator!=(const self& l)
	{
		return cur != l.cur;
	}

	bool operator==(const self& l)
	{
		return cur == l.cur;
	}
};
